package com.qububu.common.user.dto;

import java.io.Serializable;


public class UserLoginInfoDto implements Cloneable, Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2616162801426739121L;
	
	private String loginId;
	private String psw;
	private LoginType loginType;
	
	public UserLoginInfoDto(String loginId, String password) {
		this.loginId = loginId;
		this.psw = password;
	}
	
	public UserLoginInfoDto() {

	}
	
	public String getLoginId() {
		return loginId;
	}
	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}
	public String getPsw() {
		return psw;
	}
	public void setPsw(String psw) {
		this.psw = psw;
	}
	
	@Override
	public Object clone() {
		return new UserLoginInfoDto(loginId, psw);
	}

	public LoginType getLoginType() {
		return loginType;
	}
	
	public void setLoginType(LoginType loginType) {
		this.loginType = loginType;
	}
	
	public enum LoginType{
		ORDINARY(0),
		ADMIN_SYSTEM(1);
		
		private int intValue;
		private LoginType(int intValue) {
			this.intValue = intValue;
		}
		
		/**
		 * 根据传入字符串来返回对应的状态类型
		 */
		public static LoginType getLoginType(String strValue) {
			try {
				LoginType type = valueOf(strValue);
				return type;
				
			} catch (Exception e) {
				// TODO: handle exception
				throw new IllegalArgumentException("Value '" + strValue + "' is not allowed in LoginType");
			}
		}
		
		/**
		 * 根据传入int值返回对应状态类型
		 * */
		public static LoginType getLoginType(int intValue) {
			for (LoginType elem : LoginType.values()) {
				if (elem.toIntValue() == intValue) {
					return elem;
				}
			}
			
			throw new IllegalArgumentException("Value '" + intValue
					+ "' is not allowed in LoginType.");
		}

		public int toIntValue() {
			// TODO Auto-generated method stub
			return intValue;
		}
	}

}
